package com.yangjie.common.dao;

import java.io.Serializable;
import java.util.Date;

import org.hibernate.EmptyInterceptor;
import org.hibernate.type.Type;

public class TimestampInterceptor extends EmptyInterceptor {
	public boolean onSave(Object entity, Serializable id, Object[] state,
			String[] propertyNames, Type[] types) {
			for (int i = 0; i < propertyNames.length; i++) {
				if ("createDate".equalsIgnoreCase(propertyNames[i])) {
					state[i] = new Date();
					return true;
				}
			}

		return false;
	}

}
